package com.tianze.library.base;

import android.support.v4.widget.SwipeRefreshLayout;

import com.tianze.library.R;
import com.tianze.library.adapter.recycler.RecyclerBaseAdapter;

import butterknife.ButterKnife;


public abstract class BaseSwipeRefreshRecyclerFragment extends BaseRefreshFragment implements RecyclerBaseAdapter.OnItemClickListener, RecyclerBaseAdapter.OnItemLongClickListener {

    protected SwipeRefreshLayout mSwipeRefresh;

    @Override
    protected int getLayoutId() {
        return R.layout.tiza_fragment_recycler_swipe_refresh;
    }

    @Override
    protected void beforeInitView() {
        mSwipeRefresh = ButterKnife.findById(rootView, R.id.srl_refresh);
        mSwipeRefresh.setColorSchemeResources(
                R.color.colorPrimary, R.color.gray, R.color.green, R.color.orange
        );
        mSwipeRefresh.setOnRefreshListener(
                new SwipeRefreshLayout.OnRefreshListener() {
                    @Override
                    public void onRefresh() {
                        refresh();
                    }
                }
        );
    }

    @Override
    protected void onRequestFinish() {
        super.onRequestFinish();
        mSwipeRefresh.setRefreshing(false);
    }

}
